use std::net::TcpListener;
use std::io::{Read,Write};
fn main() {
    let listener=TcpListener::bind("127.0.0.1:3000").unwrap();

    println!("running on port 3000");
    //若tcpserver 只需要接受一次tcp请求
    //let result=listener.accept().unwrap();
    //incoming 返回迭代器
    for stream in listener.incoming(){
        let mut stream=stream.unwrap();
        println!("Connect eastablished");
        let mut buffer=[0;1024];

        //把传进来的数据读到buffer
        stream.read(&mut buffer).unwrap();
        stream.write(&mut buffer).unwrap();
    }
}
